<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>119-倒计时.html</title>
	<style>
		*{
			margin: 0;
			padding: 0;
		}
		body{
			background-color: #000;
		}
		#timer{
			margin-top: 100px
			font-size: 40px;
			color: #fff;
			text-align: center;
		}
	</style>
</head>
<body>
	<div id="timer">
		距离活动结束时间还有08小时20分钟30秒结束
	</div>
</body>
<script>
	function to2Str(num){
		return num<10 ? "0" + num : "" +num;
	}
	
	var oTimer = document.getElementById('timer');
	
	var endTime = new Date("2019-5-15 12:00:00");
	var timer = 0;

	function countDown(){
		console.log("aaa");
		var allMinSeconds = endTime.getTime() - Date.now();
		if(allMinSeconds <=0){
			allMinSeconds =0;
			clearInterval(timer);
	}
	var allSeconds = parseInt(allMinSeconds / 1000);
	var iHour = parseInt(allSeconds / 3600);
	var iMinute = parseInt(allSeconds % 3600 /60);
	var iSecond = parseInt(allSeconds % 3600 % 60);
	
	oTimer.innerHTMl = "距离活动结束还有" + to2Str(iHour) + "小时" +to2Str(iMinute) + "分钟" + to2Str(iSecond) + "秒结束"

	}
	timer = setInterval(countDown,1000)
	countDown();
	
</script>
</html>